#include<bits/stdc++.h>
using namespace std;
struct node{
    int d,v,a;
};
node c[100005];
int p[100005];
int main(){
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    int T;
    scanf("%d",&T);
    while(T--){
        int n,m,L,V,sum=0;
        scanf("%d%d%d%d",&n,&m,&L,&V);
        for(int i=1;i<=n;i++){
            scanf("%d%d%d",&c[i].d,&c[i].v,&c[i].a);
        }
        for(int i=1;i<=m;i++){
            scanf("%d",&p[i]);
        }
        sort(p+1,p+m+1);
        for(int i=1;i<=n;i++){
            if(c[i].d>p[m]) continue;
            if(c[i].a==0) {
                if(c[i].v>V) sum++;
            }
            else {
                long long x=1ll*c[i].v*c[i].v+1ll*2*c[i].a*(p[m]-c[i].d),y=1ll*V*V;
                if(x>y) sum++;
            }
        }
        printf("%d\n",sum);
        if(sum==0) printf("%d\n",m);
        else printf("%d\n",m-1);
    }
    return 0;
}